package com.shop.loan.model;

import lombok.Getter;
import lombok.Setter;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.annotation.sub_erupt.RowOperation;
import xyz.erupt.annotation.sub_erupt.Tpl;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.Readonly;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.ChoiceType;
import xyz.erupt.annotation.sub_field.sub_edit.DateType;
import xyz.erupt.annotation.sub_field.sub_edit.Search;
import xyz.erupt.annotation.sub_field.sub_edit.VL;
import xyz.erupt.upms.model.base.HyperModel;

import javax.persistence.*;
import java.util.Date;


@Setter
@Getter
@Erupt(
        name = "用户报告",
        orderBy = "id desc",
        power = @Power(add = false, delete = false, edit = false, viewDetails = false),
        rowOperation = {
                @RowOperation(
                        title = "探针报告",
                        icon = "fa fa-file-o",
                        mode = RowOperation.Mode.SINGLE,
                        tpl = @Tpl(
                                path = "/tpl/tanZhenByAdmin.html",
                                engine = Tpl.Engine.Thymeleaf
                        ),
                        type = RowOperation.Type.TPL,
                        ifExpr = "item.type == '探针C'",
                        ifExprBehavior = RowOperation.IfExprBehavior.HIDE
                ),
                @RowOperation(
                        title = "全景雷达报告",
                        icon = "fa fa-file-o",
                        mode = RowOperation.Mode.SINGLE,
                        tpl = @Tpl(
                                path = "/tpl/leiDaByAdmin.html",
                                engine = Tpl.Engine.Thymeleaf
                        ),
                        type = RowOperation.Type.TPL,
                        ifExpr = "item.type == '全景雷达'",
                        ifExprBehavior = RowOperation.IfExprBehavior.HIDE
                ),
        }
)
@Entity
@Table(
        name = "s_user_report",
        uniqueConstraints = {
                @UniqueConstraint(columnNames = {"idCardName", "idCardNumber", "mobile", "type", "loanOrderId"})
        }
)
public class UserReport extends HyperModel {

    /**
     * 姓名
     */
    @EruptField(
            views = @View(title = "姓名"),
            edit = @Edit(title = "姓名", search = @Search(vague = true), notNull = true)
    )
    private String idCardName;

    /**
     * 身份证号码
     */
    @EruptField(
            views = @View(title = "身份证号码", width = "200px"),
            edit = @Edit(title = "身份证号码", search = @Search(vague = true), notNull = true)
    )
    private String idCardNumber;

    /**
     * 手机号码
     */
    @EruptField(
            views = @View(title = "手机号码"),
            edit = @Edit(title = "手机号码", search = @Search(vague = true), notNull = true)
    )
    private String mobile;


    /**
     * 类型
     *
     *
     *      LeiDa(1),//全景雷达
     *     TanZhenC(2),//探针C
     *     Tlx(3),//天狼星
     */
    @EruptField(
            views = @View(title = "类型"),
            edit = @Edit(
                    title = "类型",
                    type = EditType.CHOICE,
                    search = @Search(),
                    show = false,
                    choiceType = @ChoiceType(
                            vl = {
                                    @VL(label = "探针C", value = "1"),//探针C
                                    @VL(label = "全景雷达", value = "2"),//全景雷达
//                                    @VL(label = "天狼星", value = "3"),//天狼星
                            }
                    ))
    )
    private Integer type;

    /**
     * 报告内容
     */
    @Lob
    @EruptField(
            views = @View(title = "报告内容", show = false)
    )
    private String infoJson;

    @EruptField(
            edit = @Edit(title = "三方查询id", show = false)
    )
    private String searchOrderId;


    @EruptField(
            edit = @Edit(title = "订单id", show = false)
    )
    private Long loanOrderId;


    @EruptField(
            views = @View(title = "查询时间"),
            edit = @Edit(title = "查询时间",
                    show = false,
                    readonly = @Readonly,
                    dateType = @DateType(type = DateType.Type.DATE_TIME))
    )
    @Column(name = "create_time")
    private Date createTime;
}